/*
 * @Description: 配置项预定义
 * @Author: HuiSir<https://gitee.com/huisir001>
 * @Date: 2025-08-01 16:56:07
 * @LastEditTime: 2025-09-18 17:53:39
 */
import { ref } from "vue";
import {
  ICol,
  IFormOption,
  IDetailOption,
  ListEditTableCol,
} from "../fy/types";

/* eslint-disable @typescript-eslint/no-explicit-any */
/* 预定义均使用响应式数据，便于内置组件对配置项进行调整 */
/* 这里参考钩子函数方式使用高阶函数以便传入一些参数，又不会对作用域有所污染 */

/**
 * 预定义表格列
 */
export const defineTableCols = (useTableColsFn: (...args: any[]) => ICol[]) => {
  // 这里再次套入函数，便于加装ref
  return (...args: any[]) => {
    return ref(useTableColsFn(...args));
  };
};

/**
 * 预定义列表编辑表格列
 */
export const defineListEditTableCols = (
  useListEditTableColsFn: (...args: any[]) => ListEditTableCol[]
) => {
  // 这里再次套入函数，便于加装ref
  return (...args: any[]) => {
    return ref(useListEditTableColsFn(...args));
  };
};

/**
 * 预定义表单项
 */
export const defineFormOptions = (
  useFormOptionsFn: (...args: any[]) => IFormOption[]
) => {
  return useFormOptionsFn;
};

/**
 * 预定义详情配置项
 */
export const defineDetailOptions = (
  useDetailOptionsFn: (...args: any[]) => IDetailOption[]
) => {
  return useDetailOptionsFn;
};
